package org.example.Thread02;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Dome_Thread07 {
    public static void main(String[] args) {
        List<Integer> arrayList=new ArrayList<>();
        List<Integer> list= Collections.synchronizedList(arrayList);
        for(int i=0;i<10;i++){
            int j=i+1;
            Thread t = new Thread(()->{
                list.add(j);
                System.out.println(list);
            });
            t.start();
        }
    }
}
